// app.js
const express = require("express");
const bodyParser = require("body-parser");
const routes = require("./src/routes");
const app = express();
const session = require("express-session");

app.use(session({
    name:"mySession",
    secret: "mySecretKey",
    resave: false,//是否每次都重新保存session
    saveUninitialized: true,//是否为每一个请求设置一个cookie用来请求session id
    cookie: {
        httpOnly: true,
        secure: false,
        maxAge: 3600000
    }

}))
app.use(bodyParser.urlencoded({ extended: true }));
app.use('/api', routes);

const PORT = process.env.PORT || 3090;
app.listen(PORT, () => {
    console.log(`服务器正在 ${PORT} 端口运行`);
});
